package hotgammon.handicap;

import hotgammon.common.Color;
import hotgammon.common.Game;
import hotgammon.common.Location;
import hotgammon.common.ValidatorStrategy;

public class HandicapValidatorStrategy implements ValidatorStrategy{
	private ValidatorStrategy redValidatorStrategy;
	private ValidatorStrategy blackValidatorStrategy;
	
	public HandicapValidatorStrategy(ValidatorStrategy blackValidatorStrategy, ValidatorStrategy redValidatorStrategy){
		this.blackValidatorStrategy = blackValidatorStrategy;
		this.redValidatorStrategy = redValidatorStrategy;
	}

	@Override
	public boolean isValid(Location from, Location to, int diceValue, Game game) {
		if (game.getPlayerInTurn() == Color.RED) {
			return redValidatorStrategy.isValid(from, to, diceValue, game);
		}
		if (game.getPlayerInTurn() == Color.BLACK) {
			return blackValidatorStrategy.isValid(from, to, diceValue, game);
		}
		return false;
	}

}
